/**
 * 验真档案表
 */

import {
  Entity,
  Column,
  CreateDateColumn,
  ManyToMany,
  JoinTable,
  PrimaryColumn
} from "typeorm";
import { BblAttach } from "./attach.entity";

@Entity("BBL_RECORD")
export class BblRecord {
  /**
   * 档案id
   */
  @PrimaryColumn({
    name: "RECORD_ID",
    type: "varchar",
    length: 50,
    comment: "档案ID"
  })
  recordId: string;

  /**
   * 球杆编号
   */
  @Column({
    name: "RECORD_CODE",
    type: "varchar",
    length: 255,
    comment: "球杆编号"
  })
  recordCode: string;

  /**
   * 球杆品牌
   */
  @Column({
    name: "RECORD_BRAND",
    type: "varchar",
    length: 255,
    comment: "球杆品牌"
  })
  recordBrand: string;

  /**
   * 球杆重量
   */
  @Column({
    name: "RECORD_WEIGHT",
    type: "varchar",
    length: 255,
    comment: "球杆重量"
  })
  recordWeight: string;

  /**
   * 球杆长度
   */
  @Column({
    name: "RECORD_LENGTH",
    type: "varchar",
    length: 255,
    comment: "球杆长度"
  })
  recordLength: string;

  /**
   * 球杆重心
   */
  @Column({
    name: "RECORD_CENTER",
    type: "varchar",
    length: 255,
    comment: "球杆重心"
  })
  recordCenter: string;

  /**
   * 杆头直径
   */
  @Column({
    name: "RECORD_TOP_DIAM",
    type: "varchar",
    length: 255,
    comment: "杆头直径"
  })
  recordTopDiam: string;

  /**
   * 握把直径
   */
  @Column({
    name: "RECORD_TAIL_DIAM",
    type: "varchar",
    length: 255,
    comment: "握把直径"
  })
  recordTailDiam: string;

  /**
   * 档案主图
   */
  @ManyToMany((type) => BblAttach, { createForeignKeyConstraints: false })
  @JoinTable({
    name: "BBL_RECORD_MAIN_IMG",
    joinColumn: {
      name: "RECORD_ID",
      referencedColumnName: "recordId"
    },
    inverseJoinColumn: {
      name: "ATT_ID",
      referencedColumnName: "attId"
    }
  })
  recordMainImgs: BblAttach[];

  /**
   * 档案描述
   */
  @Column({
    name: "RECORD_TEXT",
    type: "text",
    comment: "档案描述"
  })
  recordText: string;

  @CreateDateColumn({
    type: "timestamp",
    name: "CREATE_AT"
  })
  createAt: Date;
}
